<?php

namespace App\Service\Message;

use App\Helpers\AliyunUtil;
use App\Model\UserProfile;
use App\Model\VoiceText;
use App\Service\BaseService;

/**
 * 自动聊天消息设置信息
 */
class AutoMsgInfoService extends BaseService
{
    public function handle()
    {
        $userId = $this->getUserId();
        $profile = UserProfile::getProfile($userId);
        $ret = [
            //自动文字回复
            'auto_msg_text' => $profile->auto_msg_text,
            //自动语音回复
            'auto_msg_voice' => !$profile->auto_msg_voice ? '' : AliyunUtil::VOICE_HOST . $profile->auto_msg_voice,
            'auto_voice_duration' => $profile->auto_voice_duration ?: 0,
            //自动回复语音的可选文案
            'voice_text' => VoiceText::getList(30, 1),
        ];
        log_info(__CLASS__ . "=={$userId}==" . json_encode($ret));
        return $ret;
    }
}
